<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>demo</title>
</head>

<body>
<img id="logo" src="../img/logo1.jpg" alt="jQuery logo" title="jQuery logo" />
<img id="logo2" src="../img/logo2.jpg" alt="jQuery logo2" class="img-jquery2" title="jQuery logo2" />
<input type="checkbox" id="check" tabindex="1" style="width:50px; height: 50px;" title="Check this!" description="just a checkbox" />
<script src="../vendor/jquery-1.12.4.js"></script>
<script>
    $(function() {

        var img = $('img');
        //获取特性值和设置值
        console.log(img.attr('title'));
        console.log(img.attr('title','123'))

        var checkbox = $('#check');


        //        console.log(img.attr('id'));
        //        console.log(img.attr('class'));
        //
        //        console.log(checkbox.attr('tabIndex'));
        //        console.log(checkbox.attr('TABINDEX'));
        //        console.log(checkbox.attr('checked'));

        console.log(img.attr('title', 'new title'));
        console.log(img.attr({
            title: 'new title2',
            alt: 'new alt2'
        }));
        console.log(checkbox.attr({
            tabIndex: 2
        }));
        console.log(img.attr('title', function(index, previousValue) {
            return previousValue + '-' + index;
        }));

        console.log(checkbox.attr({
            tabIndex: function(index, previousValue) {
                return ++previousValue;
            }
        }));

        console.log(checkbox.prop(check)) //通过prop获取属性值,建议通过pop形式设置值为布尔的属性值
        console.log(img.removeAttr('title alt'));
        console.log(document.getElementById('logo').title);

    });
</script>
</body>

</html>